/**
 * 
 */
package imoney.client.rpc;

import imoney.shared.exception.AlreadyExistingException;
import imoney.shared.exception.NoSuchPersonException;
import imoney.shared.exception.PositionOutOfDateException;
import imoney.shared.model.Group;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * @author Arnaud PELOQUIN
 * Server-side RPC class to manage user groups.
 */
@RemoteServiceRelativePath("../service/group") 
public interface GroupService extends RemoteService  {
	
	/**
	 * Returns all the groups in which this person currently is.
	 * @param cookieValue : the raw value of the cookie found on the page
	 * to help identify the person.
	 * @return the list of groups if the person is found in the context, or
	 * null otherwise. In the late case, a redirect to Statics.LOGGING_URL is
	 * likely to be required.
	 */
	public ArrayList<Group> getGroups(String cookieValue) throws PositionOutOfDateException, NoSuchPersonException;
	
	/**
	 * Create the group and save it in the database. All concerned persons are updated w
	 * this new group.<br><br>
	 * This method doesn't perform group update, it will return silently if the group already exists.
	 * To perform updates use other specific methods.
	 * @param groupName : the name of the group to create.
	 * @param people : the list of people of this group. The Banker is the first person of the list.
	 * @return 
	 * @throws AlreadyExistingException if the group name is already in use.
	 * @throws NoSuchPersonException if one or more pseudos are not found in the database.
	 */
	Group saveGroup(String groupName, ArrayList<String> people) throws AlreadyExistingException, NoSuchPersonException;
}
